import request from '@/utils/request'
const baseUrl = process.env.VUE_APP_TMS_CONSOLE_HOST
// 获取订单列表
export function getOrderList(data) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/search`,
    method: 'post',
    data
  })
}

// 取消订单
export function postCancelOrder(id) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/${id}/cancel`,
    method: 'post',
    id
  })
}
// 终结订单
export function postFinishOrder(id) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/${id}/stop`,
    method: 'post',
    id
  })
}

// 获取订单已派单的司机信息
export function gethadSendDriver(id) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/${id}/hadSendDriver`,
    method: 'get'
  })
}

// 获取运单已派单的司机信息
export function getWayillDriver(id) {
  return request({
    url: `${baseUrl}/api/v1/tms-freight/${id}/hadSendDriver`,
    method: 'get'
  })
}

// 获取订单已派单的车队长信息
export function gethadSendCar(id) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/${id}/hadSendFleet`,
    method: 'get'
  })
}

// 新增订单
export function postOrderAdd(data) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/add`,
    method: 'post',
    data
  })
}

// 货物类型下拉列表
export function getGoodsTypeList() {
  return request({
    url: `${baseUrl}/api/v1/tms-goods-type/selector`,
    method: 'get'
  })
}
// 单位类型下拉列表
export function unitsTypeList() {
  return request({
    url: `${baseUrl}/api/v1/tms-unit/selector`,
    method: 'get'
  })
}
// 按货物名查询
export function goodsNameList(data) {
  return request({
    url: `${baseUrl}/api/v1/tms-goods/selector`,
    method: 'get',
    data
  })
}

// 搜索历史订单
export function getHistoryOrderList(data) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/searchHistory`,
    method: 'post',
    data
  })
}

// 订单详情
export function getOrderDetail(orderNo) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/${orderNo}/detail`,
    method: 'get'
  })
}

// 订单派单
export function postSendOrder(data) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/send`,
    method: 'post',
    data
  })
}
// 重新派单
export function postReSendOrder(data) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/reSend`,
    method: 'post',
    data
  })
}

// 订单导入
export function postImportOrderExcel(data) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/import`,
    method: 'post',
    data
  })
}

// 导入查询
export function postImportLogSearch(data) {
  return request({
    url: `${process.env.VUE_APP_TMS_IAM_HOST}/api/v1/common-import-log/search`,
    method: 'post',
    data
  })
}

// 修改订单
export function postUpdateOrder(data) {
  return request({
    url: `${baseUrl}/api/v1/tms-order/update`,
    method: 'post',
    data
  })
}

// 代司机接单
export function postProxyAccept(data) {
  return request({
    url: `${baseUrl}/api/v1/tms-freight/proxyAccept`,
    method: 'post',
    data
  })
}

// 添加到司机关系列表
export function postAddDriverList(id) {
  return request({
    url: `${baseUrl}/api/v1/tms-driver/add/driver-car-relation/${id}`,
    method: 'post'
  })
}

// 添加到车队长关系列表
export function postAddCarMasterList(id) {
  return request({
    url: `${baseUrl}/api/v1/tms-driver-master/add/${id}`,
    method: 'post'
  })
}
